package com.eastfair.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 开关枚举类
 * </p>
 *
 * @author zjn
 * @date 2021-08-30
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SwitchEnum", description = "开关枚举类")
public enum SwitchEnum implements BaseEnum {

    /**
     * VISITOR_REGISTER_AUDIT_CN="国内预登记审核开关"
     */
    VISITOR_REGISTER_AUDIT_CN("国内预登记审核开关"),
    /**
     * VISITOR_REGISTER_AUDIT_EN="国外预登记审核开关"
     */
    VISITOR_REGISTER_AUDIT_EN("国外预登记审核开关"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static SwitchEnum match(String val, SwitchEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SwitchEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(SwitchEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "VISITOR_REGISTER_AUDIT_CN,VISITOR_REGISTER_AUDIT_EN", example = "VISITOR_REGISTER_AUDIT_EN")
    public String getCode() {
        return this.name();
    }

}
